using System;
using System.ComponentModel;
using System.Linq.Expressions;

namespace SteamInstaller.ViewModel
{
    public class ViewModelBase : INotifyPropertyChanged 
    {
        public void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpression)
        {
            if (PropertyChanged == null)
                return;

            var memberExpression = propertyExpression.Body as MemberExpression;
            if (memberExpression == null)
                throw new ArgumentException("'propertyExpression' should be a member expression");

            PropertyChanged(this, new PropertyChangedEventArgs(memberExpression.Member.Name));
        }

        public event PropertyChangedEventHandler PropertyChanged;
    }
}
